<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="s_folder" :rules="rules" label-width="100px" id="mvcfm">
      <el-button @click="popCompanyFileUpload('')" type='primary' size="mini">上传文件</el-button>
      <el-button @click="popCompanyFileWrite('')" type='primary' size="mini">编制文件</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 文件夹 </span>
      </div>
      <el-table :data="s_folder" class="folder">
        <el-table-column label="操作" align="center" width='100' type=''>
          <template slot-scope="scope">
            <el-dropdown trigger="click">
              <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
        <el-table-column label="文件夹" prop="folder_id">
          <template slot-scope="scope">
            <el-link @click="gotoPage('/mes/systemadmin/CompanyFileNext?CMID9='+scope.row.folder_id+''+vueparams+'')" type='primary'>{{scope.row.subject}}</el-link>
          </template>
        </el-table-column>
      </el-table>
      <select>
        <option value=''>我的编制文件</option>
      </select>
      <div class="form-unit">
        <span class="mvc-title-left"> 文件列表 </span>
      </div>
      <el-table :data="s_file">
        <el-table-column label="操作" align="center" width='100' type=''>
          <template slot-scope="scope">
            <el-dropdown trigger="click">
              <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>
                  <el-link @click="pub_file('&CMID4='+scope.row.item_id+'')">发布</el-link>
                </el-dropdown-item>
                <el-dropdown-item>
                </el-dropdown-item>
                <el-dropdown-item>
                  <el-link @click="d_files('&CMID4='+scope.row.item_id+'')">删除文件</el-link>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
        <el-table-column label="文件" prop="item_id">
          <template slot-scope="scope">
            <el-link @click="gotoPage('/mes/systemadmin/CompanyFileVersion?CMID4='+scope.row.item_id+''+vueparams+'')" type='primary'>{{scope.row.client_filename}}</el-link>
          </template>
        </el-table-column>
        <el-table-column label="编制主题" prop="subject">
        </el-table-column>
        <el-table-column label="尺寸" prop="size">
        </el-table-column>
        <el-table-column label="版本" prop="version">
        </el-table-column>
        <el-table-column label="修改日期" prop="modified">
        </el-table-column>
        <el-table-column label="已发布" prop="">
        </el-table-column>
        <el-table-column label="任务编写人" prop="enteredby">
        </el-table-column>
        <el-table-column label="分配给" prop="assign_userid">
        </el-table-column>
      </el-table>
      <pagination v-show="total>0" :total="total" :limit.sync="pageSize" @pagination="getPage" />
    </el-form>
    <el-dialog :visible.sync="CompanyFileUploadVisible" append-to-body>
      <CompanyFileUpload v-if="CompanyFileUploadVisible" ref="CompanyFileUpload" :popparams="popparams"> </CompanyFileUpload>
    </el-dialog>
    <el-dialog :visible.sync="CompanyFileWriteVisible" append-to-body>
      <CompanyFileWrite v-if="CompanyFileWriteVisible" ref="CompanyFileWrite" :popparams="popparams"> </CompanyFileWrite>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import CompanyFileUpload from "@/views/mes/systemadmin/CompanyFileUpload";
  import CompanyFileWrite from "@/views/mes/systemadmin/CompanyFileWrite";
  export default {
    name: 'CompanyManagementFIle',
    components: {
      CompanyFileUpload,
      CompanyFileWrite,
    },
    props: ['popparams'],
    data() {
      return {
        CompanyFileUploadVisible: false,
        CompanyFileUploadValue: null,
        CompanyFileUploadDesc: null,
        CompanyFileWriteVisible: false,
        CompanyFileWriteValue: null,
        CompanyFileWriteDesc: null,
        vueparams: this.getVUEParams("&CMODULEID=firm"),
        s_folder: [],
        s_file: [],
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/systemadmin/FileAdminAction/companyManagementFIle?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      pub_file(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/mes/systemadmin/FileAdminAction/pub_file?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      popCompanyFileUpload(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.CompanyFileUploadVisible = !this.CompanyFileUploadVisible;
      },
      popCompanyFileWrite(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.CompanyFileWriteVisible = !this.CompanyFileWriteVisible;
      },
    },
  }
</script>
